const fs = require('fs')
const request = require('request')

exports.uploadPhoto = async (url,num,file,uploadPassword)=>{
	return new Promise( resolve => {
		const formData = {
			uploadPassword,
		    num,
		    file: fs.createReadStream(file)
		};
		request.post({
		    url,
		    formData
		}, function (err, httpResponse, body) { 
		    if (err) {
		        return resolve([`图片上传错误:学号${num},图片:${error}`])
		    }
		    resolve([null,JSON.parse(body)])
		});

	})

}